package request

import "errors"

type UserPasswordForm struct {
	Username string `json:"username"`
	Password string `json:"password"`
	NewPassword string `json:"newPassword"`
	CheckPassword string `json:"checkPassword"`
}

func (pwd_form UserPasswordForm)Validation() error {
	pwd_len, new_pwd_len, check_pwd_len := len(pwd_form.Password), len(pwd_form.NewPassword), len(pwd_form.CheckPassword)
	if pwd_len >= 6 && pwd_len <= 18 && new_pwd_len >= 6 && new_pwd_len <= 18 && check_pwd_len >= 6 && check_pwd_len <= 18{
		if pwd_form.NewPassword == pwd_form.CheckPassword {
			return nil
		}else {
			return errors.New("两次密码不一致")
		}
	}
	return errors.New("密码长度大于6小于18位")
}

type StateForm struct  {
	ID int `json:"user_id"`
	State bool `json:"state"`
}

type UserRoleForm struct {
	UserId int `form:"user_id"`
	RoleId int `form:"role_id"`
}